package bookshop.beans;

import java.util.List;

public class Page {
	private int pageNo;
	private List<Book> list;
	private int pageSize=5;
	private long totalItemNumber;
	public  Page(int no) {
		this.pageNo=no;
	}
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public List<Book> getList() {
		return list;
	}
	public void setList(List<Book> list) {
		this.list = list;
	}
	public int getPageSize() {
		return pageSize;
	}

	public long getTotalItemNumber() {
		return totalItemNumber;
	}
	public void setTotalItemNumber(long totalItemNumber) {
		this.totalItemNumber = totalItemNumber;
	}
	//判断有没有后一页
	public boolean isHasNext() {
		if(pageNo*pageSize<totalItemNumber) {
			return true;
		}
		return false;
	}
	//判断有没有前一页
	public boolean isHasPrev() {
		if(pageNo>1) {
			return true;
		}
		return false;
	}
	//得到后一页
	public int getNextPage() {
		if(isHasNext()) {
			return pageNo+1;
		}
		return pageNo;
	}
	//得到前一页
	public int getPrePage() {
		if(isHasPrev()) {
			return pageNo-1;
		}
		return pageNo;
	}
	@Override
	public String toString() {
		return "Page [pageNo=" + pageNo + ", list=" + list.size() + ", pageSize=" + pageSize + ", totalItemNumber="
				+ totalItemNumber + "]";
	}
	
}
